package pvz;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;

//图片类
public class Images {
    public static BufferedImage[] repes; //双发豌豆图片
    public static BufferedImage[] snows; //减速豌豆图片
    //给图片赋值
    static{
        for (int i=0;i<repes.length;i++){
            repes[i] = readImage("Repeater"+i+"png");//双发豌豆图片
            snows[i] = readImage("SnowPea"+i+"png"); //减速豌豆图片
        }
    }
    /**  读取图片  fileName：图片名称 */
    public static BufferedImage readImage(String fileName){
        try{
            BufferedImage img = ImageIO.read(PlantObiect.class.getResource(fileName)); //读取FlyingObjec类同包中的图片
            return img;
        }catch(Exception e){
            e.printStackTrace();
            throw new RuntimeException();
        }
    }
}
